package com.xuecheng.content.config.mq;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * <p></p>
 *
 * @Description:
 */
@Configuration
public class RabbitMQConfig {
    @Bean("coursePubEx")
    public DirectExchange simpleExchange(){
        // 三个参数：交换机名称、是否持久化、当没有queue与其绑定时是否自动删除
        return new DirectExchange("test.direct", true, false);
    }
    @Bean("coursePubQueue")
    public Queue simpleQueue(){
        // 使用QueueBuilder构建队列，durable就是持久化的
        return QueueBuilder.durable("test.queue").build();
    }
    @Bean
    public Binding errorBinding(Queue coursePubQueue, DirectExchange coursePubEx){
        return BindingBuilder.bind(coursePubQueue).to(coursePubEx).with("test");
    }
}